-
Notifications
You must be signed in to change notification settings - Fork 403
feat: add deselected state for file selection #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Introduce a new configuration option to start with all files deselected. This change affects the selection engine and allows users to control the initial selection state through command-line arguments and configuration files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds a new configuration option deselected that allows users to start with all files deselected by default. The feature integrates seamlessly with the existing selection system, properly respecting include patterns and user actions while only affecting the default behavior when no patterns match.
Changes:
- Added
deselectedboolean field to configuration structures with proper serialization support - Extended
SelectionEngineto support deselected-by-default behavior - Added command-line argument
--deselectedand UI toggle in the settings panel
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/code2prompt-core/src/configuration.rs | Added deselected field to Code2PromptConfig and TomlConfig with proper serialization |
| crates/code2prompt-core/src/selection.rs | Extended SelectionEngine with deselected_by_default field and logic, added test |
| crates/code2prompt-core/src/session.rs | Updated session to pass deselected to SelectionEngine, added set_deselected method |
| crates/code2prompt/src/args.rs | Added --deselected command-line argument |
| crates/code2prompt/src/config.rs | Merged CLI and config file values for deselected option |
| crates/code2prompt/src/model/settings.rs | Added Deselected enum variant and toggle logic |
| crates/code2prompt/src/view/formatters.rs | Added UI display for deselected setting in settings panel |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[test] | ||
| fn test_deselected_by_default() { | ||
| let mut engine = SelectionEngine::new(vec![], vec![], true); | ||
|
|
||
| // By default everything is deselected | ||
| assert!(!engine.is_selected(Path::new("main.rs"))); | ||
| assert!(!engine.is_selected(Path::new("src/lib.rs"))); | ||
|
|
||
| // User action should still work | ||
| engine.include_file(PathBuf::from("main.rs")); | ||
| assert!(engine.is_selected(Path::new("main.rs"))); | ||
| assert!(!engine.is_selected(Path::new("src/lib.rs"))); | ||
| } |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test coverage for the new deselected_by_default feature only covers the case when there are no include patterns. Consider adding a test case to verify the interaction between deselected_by_default=true and include patterns to ensure that include patterns still work as expected when this flag is enabled. For example, when deselected_by_default=true and include_patterns=["*.rs"], files matching "*.rs" should still be selected.
ODAncona
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is well integrated. However, I feel something is bad with the state mgmt of this Selection Engine.
The basic idea was to have globpattern to initiate selection and then you could select and remove files on top of that.
Then the default behavior should be something like this:
Code2prompt . => All included
Code2prompt . -i -e => Glob logic
Code2prompt . --TUI => All deselected
Code2prompt . -i -e => Glob Logic initialization
I will thoroughly test your PR and merge it if I feel it's working the intended way.
Let me know if you had something more in mind.
Thank you for your contribution ;)
Introduce a new configuration option to start with all files deselected. This change affects the selection engine and allows users to control the initial selection state through command-line arguments and configuration files.
it is helpful for --tui --deselected